]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Add a way to use the OSK on shell chrome in wayland sessions
authorRui Matos <tiagomatos@gmail.com>
Thu, 2 Apr 2015 22:18:07 +0000 (00:18 +0200)
committerRui Matos <tiagomatos@gmail.com>
Tue, 14 Apr 2015 17:34:13 +0000 (19:34 +0200)
libcaribou was designed to generate X events which works under wayland
sessions for X clients but obviously doesn't work for wayland clients
and for shell chrome.

This patch adds a simple caribou display adapter which inherits from
its X display adapter and allows us to continue to work for X clients
and at the same time makes the OSK work on shell text entries by
sending key events directly to the focused text actor.

Making the OSK work for wayland clients requires much bigger changes
at various levels in the stack and either not using libcaribou or
re-working it substantially so that's left for future work.

https://bugzilla.gnome.org/show_bug.cgi?id=747274

js/ui/keyboard.js
src/shell-util.c
src/shell-util.h

index 393a179e86cde95a414b6bbae7070dc6cc588bd6..20c45014bdb4665e61123a66cb0ddaff775256d7 100644 (file)
@@ -184,6 +184,10 @@ const Keyboard = new Lang.Class({
         this._daemonProxy = null;
         this._lastDeviceId = null;
 
+        if (Meta.is_wayland_compositor() &&
+            Caribou.DisplayAdapter.set_default)
+            Caribou.DisplayAdapter.set_default(new ShellWaylandAdapter());
+
         Meta.get_backend().connect('last-device-changed', Lang.bind(this,
             function (backend, deviceId) {
                 let manager = Clutter.DeviceManager.get_default();
@@ -725,3 +729,24 @@ const KeyboardSource = new Lang.Class({
         this._keyboard.show(Main.layoutManager.bottomIndex);
     }
 });
+
+const ShellWaylandAdapter = new Lang.Class({
+    Name: 'ShellWaylandAdapter',
+    Extends: Caribou.XAdapter,
+
+    vfunc_keyval_press: function(keyval) {
+        let focus = global.stage.get_key_focus();
+        if (focus instanceof Clutter.Text)
+            Shell.util_text_insert_keyval(focus, keyval);
+        else
+            this.parent(keyval);
+    },
+
+    vfunc_keyval_release: function(keyval) {
+        let focus = global.stage.get_key_focus();
+        if (focus instanceof Clutter.Text)
+            return;             // do nothing
+        else
+            this.parent(keyval);
+    },
+});
index b0b90d6144f3b7048b62b01c87919acf64286477..ab8a0ce5159b74d9405a23754da38a6396706f0c 100644 (file)
@@ -391,3 +391,15 @@ shell_util_need_background_refresh (void)
 
   return FALSE;
 }
+
+void
+shell_util_text_insert_keyval (ClutterActor *actor,
+                               guint         keyval)
+{
+  ClutterEvent event = { 0 };
+
+  event.type = CLUTTER_KEY_PRESS;
+  event.key.keyval = keyval;
+
+  clutter_actor_event (actor, &event, FALSE);
+}
index e7d3cc9fb9bf6efe12cf5b7a1af07f765d6212d6..4474a0d6daa09630b6ad10b677151821225de641 100644 (file)
@@ -47,6 +47,9 @@ void    shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
 
 gboolean shell_util_need_background_refresh (void);
 
+void shell_util_text_insert_keyval (ClutterActor *actor,
+                                    guint         keyval);
+
 G_END_DECLS
 
 #endif /* __SHELL_UTIL_H__ */